#include "TimeMgr.h"
#include "Game.h"
#include "OgreFrameListener.h"


void TimeMgr::stateStarted()
{
	Game::getInstance()->mRoot->addFrameListener(this);
}

void TimeMgr::stateEnded()
{
	Game::getInstance()->mRoot->removeFrameListener(this);
}

bool TimeMgr::frameRenderingQueued( const Ogre::FrameEvent& evt )
{
	for(int i=0;i<_lisNum;i++){
		Ogre::Real tp=(_listener[i]->t-=evt.timeSinceLastFrame);
		if(tp<0){
			_listener[i]->timeUp();
			removeListener(_listener[i]);
		}
	}
	return true;
}
